home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / isres.zip / ISRES.ASM next >
Assembly Source File  |  1992-01-02  |  6KB  |  175 lines

  1. ;******************************************************
  2. ;                  ISRES.ASM 1.00
  3. ;        Copyright (c) TurboPower Software 1990.
  4. ;                All rights reserved.
  5. ;******************************************************
  6.  
  7. ;****************************************************** Equates
  8.  
  9. IfcSignature1   =       0F0F0h          ;Do not change
  10. IfcSignature2   =       0E0E0h          ;Do not change
  11. WP              EQU     WORD PTR
  12.  
  13. ;****************************************************** Structures
  14.  
  15. ;Structure of a pointer
  16. Pointer STRUC
  17.         Ofst    DW      0
  18.         Segm    DW      0
  19. Pointer ENDS
  20.  
  21. ;Structure of an IFC record
  22. IfcRec  STRUC
  23.         NamePtr         Pointer <>
  24.         Ver             DW      0400h   ;!!
  25.         UserPtr         Pointer <>
  26.         PrevIfc         Pointer <>
  27.         NextIfc         Pointer <>
  28.         PrgName         DB 9 DUP (0)
  29. IfcRec  ENDS
  30.  
  31. ;****************************************************** Macros
  32.  
  33. SetPtr          MACRO   P, S, O
  34.                 MOV     P.Ofst, O       ;set offset
  35.                 MOV     P.Segm, S       ;set segment
  36.                 ENDM
  37.  
  38. SetPtrByOfst    MACRO   P, S, O
  39.                 MOV     AX,Offset O
  40.                 MOV     P.Ofst, AX      ;set offset
  41.                 MOV     P.Segm, S       ;set segment
  42.                 ENDM
  43.  
  44. ;****************************************************** Data
  45.  
  46. DATA    SEGMENT BYTE PUBLIC
  47.  
  48.         EXTRN   ThisIfcPtr : DWORD
  49.         EXTRN   IfcInstalledPtr : DWORD
  50.  
  51. DATA    ENDS
  52.  
  53. ;****************************************************** Code
  54.  
  55. CODE    SEGMENT BYTE PUBLIC
  56.  
  57.         ASSUME  CS:CODE,DS:DATA
  58.  
  59.         PUBLIC  Init16, Restore16, ThisIfc
  60.  
  61. OldInt16        Pointer <>
  62. ThisIfc         IfcRec  <>
  63. IsrInstalled    DB      0               ;!!
  64. IfcInstalled    DB      0
  65.  
  66. ;****************************************************** Int16
  67.  
  68. IntraApp        =       00F0h           ;offset of intraapplication comm area
  69. BiosDataSeg     =       40h             ;segment of BIOS data area
  70.  
  71. Int16   PROC NEAR
  72.  
  73.         STI                             ;Interrupts on
  74.         CMP     CS:IfcInstalled,1       ;Are we in charge of the interface?
  75.         JNE     JumpOld16               ;If not, chain to old ISR
  76.         CMP     AX,IfcSignature1        ;See if this is a request for info
  77.         JNE     NotIfcCheck1            ;If not, continue
  78.         NOT     AX                      ;Flip the bits in AX
  79.         PUSH    CS                      ;ES = CS
  80.         POP     ES
  81.         MOV     DI,Offset ThisIfc       ;ES:DI points to ThisIfc
  82.         MOV     WP ES:[DI].NextIfc,0    ;If we're answering this, we're the end
  83.         MOV     WP ES:[DI].NextIfc+2,0  ; of the line, so NextIfc is nil
  84.         IRET
  85.  
  86. NotIfcCheck1:
  87.         CMP     AX,IfcSignature2        ;Is this a secondary request?
  88.         JNE     JumpOld16
  89.         NOT     AX                      ;Flip the bits in AX
  90.         PUSH    ES                      ;save registers
  91.         PUSH    DI
  92.         PUSH    BX
  93.         PUSH    CX
  94.         MOV     CX,BiosDataSeg          ;ES:DI => intra-app comm area
  95.         MOV     ES,CX
  96.         MOV     DI,IntraApp
  97.         MOV     CX,CS                   ;CX:BX => ActualIfc
  98.         MOV     BX,Offset ThisIfc
  99.         MOV     ES:[DI].Ofst,BX         ;store @ThisIfc at Ptr(ES,DI)^
  100.         MOV     ES:[DI].Segm,CX
  101.         MOV     ES,CX                   ;ES:BX points to ThisIfc
  102.         MOV     WP ES:[BX].NextIfc,0    ;If we're answering this, we're the end
  103.         MOV     WP ES:[BX].NextIfc+2,0  ; of the line, so NextIfc is nil
  104.         POP     CX
  105.         POP     BX
  106.         POP     DI
  107.         POP     ES
  108.         IRET
  109.  
  110. JumpOld16:
  111.         CLI                             ;Interrupts off
  112.         JMP     DWORD PTR CS:OldInt16   ;Jump to old vector
  113.  
  114. Int16   ENDP
  115.  
  116. ;****************************************************** Init16
  117.  
  118. ;procedure Init16;
  119.  
  120. ;Capture INT 16
  121.  
  122. Init16  PROC FAR
  123.  
  124.         CMP     CS:IsrInstalled,0       ;!!
  125.         JNE     IExit                   ;!!
  126.  
  127.         ;set up IFC
  128.         SetPtrByOfst    ThisIfc.NamePtr, CS, ThisIfc.PrgName
  129.  
  130.         ;give Pascal routines access to CS-relative data
  131.         SetPtrByOfst    ThisIfcPtr, CS, ThisIfc
  132.         SetPtrByOfst    IfcInstalledPtr, CS, IfcInstalled
  133.  
  134.         MOV     AX,3516h                ;Get the current INT $16 vector
  135.         INT     21h
  136.         SetPtr  CS:OldInt16, ES, BX     ;save it
  137.  
  138.         PUSH    DS                      ;save DS
  139.         PUSH    CS                      ;DS:DX => Int16
  140.         POP     DS
  141.         MOV     DX,Offset Int16
  142.         MOV     AX,2516h                ;take over the vector
  143.         INT     21h
  144.         POP     DS                      ;restore DS
  145.         MOV     CS:IsrInstalled,1       ;!!
  146. IExit:                                  ;!!
  147.         RET
  148.  
  149. Init16  ENDP
  150.  
  151. ;****************************************************** Restore16
  152.  
  153. ;procedure Restore16;
  154.  
  155. ;Restore INT 16
  156.  
  157. Restore16       PROC FAR
  158.  
  159.         CMP     CS:IsrInstalled,0       ;!!
  160.         JE      RExit                   ;!!
  161.         PUSH    DS                      ;save DS
  162.         LDS     DX,CS:OldInt16          ;DS:DX has old vector
  163.         MOV     AX,2516h                ;restore it
  164.         INT     21h
  165.         POP     DS                      ;restore DS
  166.         MOV     CS:IsrInstalled,0       ;!!
  167. RExit:                                  ;!!
  168.         RET
  169.  
  170. Restore16       ENDP
  171.  
  172. CODE    ENDS
  173.  
  174.         END
  175.